package com.xca.znb.presenter;

import com.xca.znb.contact.FriendsContact;
import com.xca.znb.entity.Collect;
import com.xca.znb.entity.Trends;
import com.xca.znb.entity.User;
import com.xca.znb.model.imodel.IFriends;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class FriendsPresenter {
    private FriendsContact friendsContact ;
    protected IFriends iFriends ;
    public FriendsPresenter(FriendsContact contact , IFriends iFriends){
        this.friendsContact = contact ;
        this.iFriends = iFriends ;
    }

    public List<Trends> friendsList(String user){
        List<Collect> collectArrayList = new ArrayList<>();
        List<Trends> trendsList = new ArrayList<>();
        List<Trends> getTrendsList = new ArrayList<>();
        ArrayList<Integer> ids = new ArrayList<>();
        String collectType = "store" ;

        collectArrayList = iFriends.getCollects(user , collectType);
        trendsList = iFriends.getTrends();
        for (Trends trends : trendsList){
            for (Collect collect : collectArrayList){
                if (trends.getPublisher().equals(collect.getgID())){
                    getTrendsList.add(trends);
                }
            }
        }

        return getTrendsList ;
    }

    public User getUserByPhone(String phone){
        return iFriends.getUserByPhone(phone);
    }
    public List<Collect> getCollects(String user, String type) {
        return iFriends.getCollects(user, type);
    }

    public List<Trends> getTrends() {
        return iFriends.getTrends();
    }

    public List<Trends> getTrendsByUser(String user) {
        return iFriends.getTrendsByUser(user);
    }

    public Trends getTrendsById(int id) {
        return iFriends.getTrendsById(id);
    }

    public Collect getCollect(String gId, String type, String user) {
        return iFriends.getCollect(gId, type, user);
    }
    public void addCollect(String gId, String type, String user) {
        iFriends.addCollect(gId, type, user);
    }

    public void onFriendsMyPublishBtnClick(){
        friendsContact.onFriendsMyPublishBtnClick();
    }
    public void onFriendsLatestClick(){
        friendsContact.onFriendsLatestClick();
    }
    public void onFriendsConcernClick(){
        friendsContact.onFriendsConcernClick();
    }
    public void onFriendsToPublishBtnClick(){
        friendsContact.onFriendsToPublishBtnClick();
    }
}
